<?php
session_start();
require_once "config/inc.php";
/**
 *Author:淡心心心
 *Date:2021/4/8
 *Time:19:15
 */
$name = $_POST['name'];
$passwd = $_POST['pass'];

$conn = new mysqli($mysqlinfo['host'],$mysqlinfo['user'],$mysqlinfo['passwd'],$mysqlinfo['dbname'],$mysqlinfo['port']);
if($conn->connect_error){
    die("链接失败$conn->connect_error");
}


$data = [];
if(empty($name)||empty($passwd)){
    echo json_encode(['status'=>200,'msg'=>"信息不能为空"]);
    die();
}

$sql = "select password from user where user='{$name}'";

$result = $conn->query($sql);


if($result->num_rows>0){
   while ($row = $result->fetch_assoc()){
      $password = $row['password'];
   }
}
if($passwd==$password){
    $_SESSION['login'] = 1;
    echo json_encode(['status'=>200,'msg'=>"登录成功"]);
}else{
    echo json_encode(['status'=>400,'msg'=>"登录失败"]);
}
$conn->close();




